package factory;

import factory.ballPen.BallPen;
import factory.ballPen.BlueBallPen;
import factory.pen.PenCore;
public class test {
    int sharedVariable = 0;
    public static void main(String[] args){
         factoryMethodPattern();
     }
    public static void factoryMethodPattern(){
        PenCore penCore;
        BallPen ballPen;
        ballPen = new BlueBallPen();
        penCore = ballPen.getPenCore();
        penCore.writeWord("hello");
    }
    public void test1(){

        Thread thread1 = new Thread(() -> {
            for (int i = 0; i < 10000; i++) {
                sharedVariable++;
            }
        });
        Thread thread2 = new Thread(() -> {
            for (int i = 0; i < 10000; i++) {
                sharedVariable++;

            }
        });

        thread1.start();
        thread2.start();

        try {
            thread1.join();
            thread2.join();
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

        System.out.println("Final value of sharedVariable: " + sharedVariable);

    }

}
